<template>
  <div class="app-container">
    <div v-if="user">
      <el-row :gutter="20">

        <el-col :span="6" :xs="24">
               <about :user="user" />
        </el-col>

        <el-col :span="18" :xs="24">
          <el-card>
            <el-tabs v-model="activeTab">
              <el-tab-pane label="账户" name="account">
                  <account :user="user" />
              </el-tab-pane>
              <el-tab-pane label="修改密码" name="password">
                  <password :user="user"/>
              </el-tab-pane>
              <el-tab-pane label="头像修改" name="avatar">
                <avatar :user="user"/>
              </el-tab-pane>
            </el-tabs>
          </el-card>
        </el-col>
  
      </el-row>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import about from './about.vue'
import {getInfo} from '@/api/user'
import {getUserId} from '@/utils/auth'
import account from './Account.vue'
import password from './password.vue'
import avatar from './avatar.vue'
export default {
  name: 'Profile',
  components: {  about,account,password,avatar},
  data() {
    return {
      user: {
      },
      activeTab: 'account'
    }
  },
  computed: {
    ...mapGetters([
      'name',
      'avatar',
      'password'
    ])
  },
  created() {
    this.getUser()
  },
  methods: {
    getUser() {
        getInfo(getUserId()).then(res=>{
           this.user=res.data.user
        })
    }
  }
}
</script>
